/**
 * Created by ming on 2016/1/22.
 */
class WinUI extends eui.Component{
    public constructor() {
        super();
        this.skinName = "WinUISkin";
    }

    protected createChildren() {
        super.createChildren();
        this.tuichuBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.tuichuFunc,this);
        this.jixuBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.jixuFunc,this);
    }

    private tuichuBtn:eui.Image;
    private jixuBtn:eui.Image;
    public playAction()
    {
        var dragonbonesData = RES.getRes( "win3" );
        var textureData = RES.getRes( "win2" );
        var texture = RES.getRes( "win1" );
        var dragonbonesFactory: dragonBones.EgretFactory = new dragonBones.EgretFactory();
        dragonbonesFactory.addDragonBonesData(dragonBones.DataParser.parseDragonBonesData(dragonbonesData));
        dragonbonesFactory.addTextureAtlas(new dragonBones.EgretTextureAtlas(texture,textureData));
        var armature: dragonBones.Armature = dragonbonesFactory.buildArmature("armatureName");
        this.addChild(armature.display);
        armature.display.x = 275;
        armature.display.y = 290;
        dragonBones.WorldClock.clock.add(armature);

        armature.addEventListener(egret.Event.COMPLETE,function(){
            dragonBones.WorldClock.clock.remove(armature);

        },this);
        armature.animation.gotoAndPlay("zq_win_01a",-1,-1,1);

    }

    private tuichuFunc()
    {
        if(this.parent)
        {
            this.parent.removeChild(this);
        }
        TableUI.Instance().quitFunc();
    }

    private jixuFunc()
    {
        if(this.parent)
        {
            this.parent.removeChild(this);
        }
        TableUI.Instance().againFunc();
    }

}